<?php

namespace app\admin\model;

class OauthOrderClass extends \app\common\model\OauthOrderClass
{
    public static function getColumnByOrder($orderIds)
    {
        $model = static::field('order_id, class_type, money')
            ->where('order_id', 'in', $orderIds)
            ->select()
            ->toArray();
        $result = [];
        foreach ($model as $key => $value) {
            $result[$value['order_id']][$value['class_type']] = $value['money'];
        }
        return $result;
    }
    
    /**
     * 删除订单表 购买的班级记录
     * @param $id
     */
    public static function deleteOne($orderIds)
    {
        $model = static::field('id,order_id')
            ->where('order_id', 'in', $orderIds)
            ->find();
        self::deleteOrderClass($model['id']);
    }
    
    /**
     * 删除订单表 购买的班级记录
     * @param $id
     */
    public static function deleteOrderClass($id)
    {
        $model = static::get($id);
        if ($model) {
            $model->delete();
        }
    }
}